<template>
	<el-main>
		<!-- <el-row :gutter="15">
			<el-col :lg="24">
				<el-card shadow="never" header="我的常用">
					<myapp></myapp>
				</el-card>
			</el-col>
		</el-row> -->
		<el-row :gutter="15">
			<el-col :lg="8">
				<el-card class="box-card pr" shadow="never" style="height: 202px;">
					<template #header>
						<sc-statistic title="销售总额" :value="transaction.total_sales_amount || 0" suffix="元" tips="销售总额" groupSeparator cols></sc-statistic>
					</template>
				</el-card>
			</el-col>
			<el-col :lg="8">
				<el-card class="box-card pr" shadow="never" style="height: 202px;">
					<template #header>
						<sc-statistic title="成交订单" :value="transaction.total_done_count || 0" suffix="笔" tips="累计成交订单数量" groupSeparator cols></sc-statistic>
					</template>
				</el-card>
			</el-col>
			<el-col :lg="8">
				<el-card class="box-card pr" shadow="never" style="height: 202px;">
					<template #header>
						<sc-statistic title="总用户数" :value="userCount.total || 0" suffix="人" tips="注册用户数" groupSeparator cols>
					</sc-statistic>
					</template>
				</el-card>
			</el-col>
		</el-row>
		<el-row :gutter="20" class="panel-group">
			<el-col :xs="12" :sm="12" :lg="8" class="card-panel-col">
				<div class="card-panel">
					<el-row :gutter="20" class="panel-group">
						<el-col :xs="12" :sm="12" :lg="12">
							<h3>学时排行榜</h3>
						</el-col>
					</el-row>
					<div class="ct-rank-bd js-tab-sec" v-loading="rankLoading">
						<template v-for="(item, index) in learnRank">
							<li v-if="item.id" class="ct-rank-item ct-rank-item--light" :key="index">
								<div class="ct-rank-item__l">
									<img v-if="index == 0" class="ct-rank-item__img-icon"
										src="/admin/dist/img/pic1.png" />
									<img v-if="index == 1" class="ct-rank-item__img-icon"
										src="/admin/dist/img/pic2.png" />
									<img v-if="index == 2" class="ct-rank-item__img-icon"
										src="/admin/dist/img/pic3.png" />
									<div v-if="index > 2" class="ct-rank-item__l f16 jdjz fb"
										style="width:20px; height:25px;">
										{{ index + 1 }}
									</div>
								</div>
								<div class="ct-rank-item__r">
									<div class="pull-left">
										<a class="js-user-card" data-card-url="/user/2/card/show" data-user-id="2">
											<img class="ct-rank-item__img"
												:src="item.photo_url ? item.photo_url : toux" />
										</a>
									</div>
									<div class="pull-left mlm" style="margin-top: 12px">
										<div class="ct-rank-item_name" title="item.name">{{ item.name }}</div>
									</div>
									<div class="ct-rank-item__date pull-right">{{ item.time }} 分钟</div>
								</div>
							</li>
							<li class="ct-rank-item ct-rank-item--light" :key="item.id" v-else>
								<div class="ct-rank-item__l">
									<div class="ct-rank-item__label o-ct-empty__label"></div>
								</div>
								<div class="ct-rank-item__r">
									<div class="pull-left">
										<a class="js-user-card fl" href="javascript:;">
											<div class="o-ct-empty-card"></div>
										</a>
									</div>
									<div class="pull-left mlm">
										<div class="o-ct-empty_name"></div>
										<div class="o-ct-empty_date"></div>
									</div>
								</div>
							</li>
						</template>
					</div>
				</div>
			</el-col>
			<el-col :lg="16">
				<echarts :echartsData="echartsData"></echarts>
			</el-col>
		</el-row>
	</el-main>
</template>

<script>
import myapp from './components/myapp';
import echarts from './components/echarts';
export default {
	components: {
		myapp,
		echarts
	},
	data() {
		return {
			dataObj: {},
			transaction: {
				total_sales_amount: 0,
				total_refund_amount: 0,
				total_done_count: 0,
				total_cancel_count: 0
			},
			userCount: {
				total: 0
			},
			learnRank: [],
			rankLoading: false,
			echartsData: []
		}
	},
	mounted() {
		this.$emit('on-mounted')
		this.getlist()
	},
	methods: {
		// 获取数据
		async getlist() {
			let res = await this.$HTTP.get('common/home');
			if (res.error == 0) {
				this.transaction = res.data.transaction
				this.userCount = res.data.userCount
				this.echartsData = res.data.courseLearn
				let rankData = [];
				for (let i = 0; i < 5; i++) {
					if (res.data.rank[i]) {
						rankData.push(res.data.rank[i])
					} else {
						rankData.push({
							id: '',
							name: ''
						})
					}
				}
				this.learnRank = rankData
			}
		}
	}
}
</script>

<style lang="scss" scoped>
.up {
	color: #F56C6C;
	margin-left: 5px;
}

.down {
	color: #67C23A;
	margin-left: 5px;
}

.flex-content {
	display: flex;
}

.paihang .items {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 15px;
}

.paihang .items .userimg {
	width: 30px;
	height: 30px;
	border-radius: 100%;
	margin-right: 10px;
}

.paihang .icon {
	width: 20px;
}

.paihang h2 {
	font-weight: 400;
	font-size: 12px;
}

.paihang .leftbox {
	display: flex;
	align-items: center;
}

.paihang .boxs {
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: relative;
	text-align: center;
	margin-bottom: 20px;
	border-bottom: 1px solid #e6e6e6;
	padding: 20px 0;
	border-top: 1px solid #e6e6e6;
}

.paihang .boxs>div {
	flex: 1;
	position: relative;
}

.paihang .boxs>div:after {
	content: '';
	display: block;
	position: absolute;
	right: 0;
	top: 0;
	height: 100%;
	width: 1px;
	background: #e6e6e6;
}

.paihang .boxs>div:last-child::after {
	display: none;
}

::v-deep .study-card .el-card__body {
	padding: 10px 15px !important;
}

.other-info {
	border-top: 1px solid #e6e6e6;
	padding: 10px 20px;
	position: absolute;
	left: 0;
	bottom: 0;
	right: 0;
}

.card-body {
	padding: 9px 20px 15px;
}

.panel-group {
	margin-top: 0;

	.card-panel-col {
		margin-bottom: 20px;
		padding-right: 10px !important;
		padding-left: 10px !important;
	}

	.card-panel {
		height: 500px;
		cursor: pointer;
		font-size: 12px;
		position: relative;
		overflow: hidden;
		color: #666;
		background: #fff;
		box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.05);
		border-color: rgba(0, 0, 0, 0.05);
		padding: 0px 20px;

		h3 {
			font-size: 16px;
			font-weight: 500;
			padding-top: 20px;
			display: inline-block;
		}

		&:hover {
			.card-panel-icon-wrapper {
				color: #fff;
			}

			.icon-people {
				background: #399afb;
			}

			.icon-message {
				background: #4c9fef;
			}

			.icon-money {
				background: #ff9f00;
			}

			.icon-shopping {
				background: #f9646a;
			}
		}

		.icon-people {
			color: #399afb;
		}

		.icon-message {
			color: #4c9fef;
		}

		.icon-money {
			color: #ff9f00;
		}

		.icon-shopping {
			color: #f9646a;
		}

		.card-panel-icon-wrapper {
			float: left;
			margin: 14px 0 0 14px;
			padding: 16px;
			transition: all 0.38s ease-out;
			border-radius: 6px;
		}

		.card-panel-icon {
			float: left;
			font-size: 48px;
		}

		.card-panel-description {
			float: right;
			font-weight: bold;
			margin: 26px;
			margin-left: 0px;
			text-align: right;

			.card-panel-text {
				line-height: 18px;
				color: rgba(0, 0, 0, 0.45);
				font-size: 16px;
				margin-top: 12px;
			}

			.card-panel-num {
				font-size: 20px;
			}
		}
	}
}

.ct-rank-bd .ct-rank-item--light {
	border-bottom: 1px solid #f5f5f5;
}

.ct-rank-item {
	padding: 24px 0;
	border-radius: 2px;
}

.ct-rank-item__l {
	border-radius: 2px;
	float: left;
}

.ct-rank-item__r {
	margin-left: 32px;
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	word-wrap: normal;
}

li {
	list-style-type: none;
}

.o-ct-empty__label,
.o-ct-item__label {
	width: 20px;
	height: 20px;
	line-height: 20px;
	text-align: center;
	border-radius: 2px;
}

.o-ct-empty__label {
	background: #f5f5f5;
}

.ct-rank-item__label {
	height: 20px;
	width: 20px;
	margin-top: 11px;
	font-size: 12px;
	color: #fff;
	line-height: 20px;
	text-align: center;
	background: #c1c1c1;
	border: none;
	border-radius: 2px;
}

.pull-left {
	float: left !important;
}

.mlm {
	margin-left: 10px !important;
}

.o-ct-empty_date,
.o-ct-empty_name {
	height: 10px;
	background: #f5f5f5;
	cursor: pointer;
}

.o-ct-empty_name {
	width: 60px;
	margin: 8px 0;
}

.o-ct-empty_date {
	width: 40px;
}

.o-ct-empty_date,
.o-ct-empty_name {
	height: 10px;
	background: #f5f5f5;
	cursor: pointer;
}

.js-user-card {
	display: inline-block;
}

.fl {
	float: left;
}

.o-ct-empty-card {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: #f5f5f5;
}

.ct-rank-item__img-icon {
	height: 30px;
	width: 22px;
	margin-top: 5px;
}

.ct-rank-item_post {
	padding-top: 4px;
	max-width: 100px;
	font-size: 12px;
	color: #909399;
	line-height: 16px;
	cursor: pointer;
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	word-wrap: normal;
}

.ct-rank-item_name {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	word-wrap: normal;
}

.ct-rank-item_name {
	max-width: 90px;
	font-size: 14px;
	color: #303133;
	line-height: 20px;
}

.ct-rank-item__img {
	display: block;
	width: 40px;
	height: 40px;
	border-radius: 10000000px;
	border-radius: 10000px;
}

.ct-rank-item__date {
	font-size: 12px;
	color: #606266;
	text-align: right;
	line-height: 16px;
	margin-top: 14px;
}

.actived {
	color: #399afb;
	border-color: #399afb;
	color: #fff;
	background-color: #399afb;
}
</style>
